package com.dgshanger.sanhxiaofeisc.mvp.presenter

import com.dgshanger.sanhxiaofeisc.entity.GoodsDetailsEntity
import com.dgshanger.sanhxiaofeisc.mvp.contract.GoodsDetailsContract
import com.dgshanger.sanhxiaofeisc.mvp.model.GoodsDetailsModel
import com.xx.baseuilibrary.mvp.BaseMvpPresenter
import com.xx.baseutilslibrary.network.rx.XxBaseHttpObserver

/**
 * Created by JacobHHH on 2018/4/20.
 */
class GoodsDetailsPresenter : BaseMvpPresenter<GoodsDetailsContract.Model, GoodsDetailsContract.View>(), GoodsDetailsContract.Presenter {

    override fun loadData(good_id: String?) {
        getModel().loadData(good_id,object : XxBaseHttpObserver<GoodsDetailsEntity>(){

            override fun onCompleted(msg: String?, entity: GoodsDetailsEntity?) {
                getView()?.setData(entity)
            }

            override fun onError(error: String?) {
                getView()?.showToast(error)
                getView()?.onDataFailure(error)
            }

            override fun onStart() {

            }

            override fun onFinish() {

            }

        })
    }

    override fun createModel(): GoodsDetailsContract.Model = GoodsDetailsModel()
}